﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace GOF23.Singleton
{
    /// <summary>
    /// 线程不安全
    /// 当两个线程同时运行到  if (instance == null)
    /// 则会创建连个实例。
    /// </summary>
    public sealed class Singleton1
    {
        private static Singleton1 instance = null;
        private Singleton1() { }
        public static Singleton1 Instance 
        { 
            get 
            {
                if (instance == null)
                {
                    instance = new Singleton1();
                }
                return instance; 
            } 
        }
    }
}
